<template>
	<div>
		<div v-if='payStatus'>
			  支付成功
			  <button>回到首页</button>
		</div>
		<div v-else>
			支付失败
		</div>
	</div>
  
</template>

<script>
import http from "@/common/api/request.js";
import qs from "qs";
export default {
  name: "Payment",
  data(){
	  return{
		  payStatus:false,
	  }
  },
  created() {
    this.getData();
  },
  methods: {
    getData() {
      console.log(this.$route.query);
      //获取支付完成返回的rul信息
      let data = {
        out_trade_no: this.$route.query.out_trade_no,
        trade_no: this.$route.query.trade_no,
      };

      http
        .$axios({
          url: "/api/successPayment",
          method: "post",
          headers: {
            token: true,
            // "Content-type": "application/x-www-form-urlencoded", //支付时需要这句
          },
          data: qs.stringify(data),
        })
        .then((res) => {
          if(res.code == 2){
			  this.payStatus=true;
		  }
        });
    },
  },
};
</script>

<style></style>
